package be.kuleuven.mume.framework;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class Vraag implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4665776878413049771L;
	
	private static final String URL = Mobilenvi.getSingelton().BASEURL + "/api/vraag/";
	public static final String ADD_URL = Mobilenvi.getSingelton().BASEURL + "/api/vraag/add";
	public static final String UPDATE_URL = Mobilenvi.getSingelton().BASEURL + "/api/vraag/update";
	
	public static final String VRAAG = "vraag";
	
	private String id;
	private String onderwerp;
	private String vraag;
	private String vakId;
	private List<String> antwoorden;
	
	public Vraag(){
		id="";
		onderwerp="";
		vraag="";
		vakId="";
		antwoorden = new ArrayList<String>();
	}
	
	public Vraag(String title, String body, String vakId) {
		setVakId(vakId);
		setSubject(title);
		setText(body);
		antwoorden = new ArrayList<String>();
	}
	
	public Vraag(String title, String body) {
		setId(id);
		setSubject(title);
		setText(body);
		antwoorden = new ArrayList<String>();
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	
	public boolean hasId(){
		if(this.id == null || this.id.equals(""))
			return false;
		return true;
	}

	public String getVakId() {
		return vakId;
	}


	public void setVakId(String vakId) {
		this.vakId = vakId;
	}

	public String getSubject() {
		return onderwerp;
	}
	public void setSubject(String title) {
		this.onderwerp = title;
	}
	public String getText() {
		return vraag;
	}
	public void setText(String vraag) {
		this.vraag = vraag;
	}

	public List<String> getAntwoorden() {
		return antwoorden;
	}

	public void setAntwoorden(List<String> antwoorden) {
		this.antwoorden = antwoorden;
	}
	
	public void addAntwoord(String antwoordId) {
		this.antwoorden.add(antwoordId);
	}
	
	public static String getUrl(String vakId){
		return URL + vakId;
	}
	
	@Override
	public boolean equals(Object o) {
		if(!this.hasId())
			return false;
		
		if(Vraag.class.isInstance(o)) {
			return this.getId().equals(((Vraag)o).getId());
		}
		return false;
	}
}
